package zero.tech.games.gate.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import zero.tech.core.data.Resp;
import zero.tech.core.data.SimpleUser;
import zero.tech.games.gate.data.entity.ReqPermission;
import zero.tech.games.gate.service.api.IClubMemberService;
import zero.tech.wsnet.data.CheckPipeiQueue;
import zero.tech.wsnet.data.CheckUserLastRoom;

@RestController
public class ClubMemberController extends BaseController{
	@Autowired
	private IClubMemberService clubMemberService;
	
	
	@RequestMapping("/club/member/add-member")
	public Resp addMember(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.addMember(simpleUser,uid,club_id);
	}
	
	@RequestMapping("/club/member/look-user")
	public Resp lookUser(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.lookUser(simpleUser,uid);
	}
	
	@RequestMapping("/club/member/look-member")
	public Resp lookMember(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.lookMember(simpleUser,club_id,uid);
	}
	
	@RequestMapping("/club/member/look-sub-member")
	public Resp lookSubMember(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.lookSubMember(simpleUser,club_id,uid);
	}
	
	
	@RequestMapping("/club/member/direct-members")
	public Resp directMembers(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		int type=Integer.valueOf(map.get("type").toString());
		return clubMemberService.directMembers(simpleUser,club_id,page,pageLength,type);
	}
	
	@RequestMapping("/club/member/hehuoren-line-totaltea")
	public Resp hehuorenLineTotalTea(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.hehuorenLineTotalTea(simpleUser,club_id,uid);
	}
	
	@CheckUserLastRoom
	@CheckPipeiQueue
	@RequestMapping("/club/member/add-money")
	public Resp addMoney(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		long gold=Integer.valueOf(map.get("gold").toString());
		int type=Integer.valueOf(map.get("type").toString());
		return clubMemberService.addMoney(simpleUser,club_id,uid,gold,type);
	}
	
	@RequestMapping("/club/member/sethehuoren")
	public Resp setHehuoren(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.setHehuoren(simpleUser,club_id,uid);
	}
	
	@RequestMapping("/club/member/delhehuoren")
	public Resp delHehuoren(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.delHehuoren(simpleUser,club_id,uid);
	}
	
	
	@RequestMapping("/club/member/kick-room")
	public Resp kickRoom(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.KickRoom(simpleUser,club_id,uid);
	}
	
	
	@RequestMapping("/club/member/frozen-person")
	public Resp frozenPerson(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.frozenPerson(simpleUser,club_id,uid);
	}
	
	
	@RequestMapping("/club/member/cancle-frozen-person")
	public Resp cancleFrozenPerson(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.cancleFrozenPerson(simpleUser,club_id,uid);
	}
	
	
	
	
	@RequestMapping("/club/member/frozen-line")
	public Resp frozenLine(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.frozenLine(simpleUser,club_id,uid);
	}
	
	@RequestMapping("/club/member/frozen-person-gold")
	public Resp frozenPersonGold(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		long gold=Integer.valueOf(map.get("gold").toString());
		return clubMemberService.frozenPersonGold(simpleUser,club_id,uid,gold);
	}
	
	@RequestMapping("/club/member/cancle-frozen-person-gold")
	public Resp cancleFrozenPersonGold(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		long gold=Integer.valueOf(map.get("gold").toString());
		return clubMemberService.cancleFrozenPersonGold(simpleUser,club_id,uid,gold);
	}
	
	
	@RequestMapping("/club/member/select-hehuoren-power")
	public Resp selectHehuorenPower(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.selectHehuorenPower(simpleUser,club_id,uid);
	}
	
	
	@RequestMapping("/club/member/sethehuoren-power")
	public Resp setHehuorenPower(HttpServletRequest request,@RequestBody ReqPermission reqPermission) {
		SimpleUser simpleUser=super.getLoginUser(request);
		return clubMemberService.setHehuorenPower(simpleUser,reqPermission);
	}
	
	@RequestMapping("/club/member/sethehuoren-fanyong")
	public Resp setHehuorenFanyong(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		float fanyong=Float.valueOf(map.get("fanyong").toString());
		return clubMemberService.setHehuorenFanyong(simpleUser,club_id,uid,fanyong);
	}
	
	
	@RequestMapping("/club/member/create-game-rule")
	public Resp createGameRule(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int game_id=Integer.valueOf(map.get("game_id").toString());
		String pipei_key=map.get("pipei_key").toString();
		String class_name=map.get("class_name").toString();
		String config_str=map.get("config_str").toString();
		int fzb_playernum=Integer.valueOf(map.get("fzb_playernum").toString());
		return clubMemberService.createGameRule(simpleUser,club_id,game_id,pipei_key,class_name,config_str,fzb_playernum);
	}
	
	
	@RequestMapping("/club/member/select-game-rules")
	public Resp selectGameRules(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		String class_name=map.get("class_name").toString();
		return clubMemberService.selectGameRules(simpleUser,club_id,class_name,page,pageLength);
	}
	
	@RequestMapping("/club/member/switch-game-rule")
	public Resp switchGameRules(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int rule_id=Integer.valueOf(map.get("rule_id").toString());
		int open=Integer.valueOf(map.get("switch").toString());
		return clubMemberService.switchGameRules(simpleUser,club_id,rule_id,open);
	}
	
	
	@CheckUserLastRoom
	@CheckPipeiQueue
	@RequestMapping("/club/member/operate-baoxiangui")
	public Resp operateBaoxiangui(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		long gold=Integer.valueOf(map.get("gold").toString());
		int type=Integer.valueOf(map.get("type").toString());
		return clubMemberService.operateBaoxiangui(simpleUser,club_id,gold,type);
	}
	
	
	@RequestMapping("/club/member/edit-notice")
	public Resp editNotice(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		String notice=map.get("notice").toString();
		return clubMemberService.editNotice(simpleUser,club_id,notice);
	}
	
	@RequestMapping("/club/member/kick-club")
	public Resp kickClub(HttpServletRequest request,@RequestBody Map<String,Object> map) {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int uid=Integer.valueOf(map.get("uid").toString());
		return clubMemberService.kickClub(simpleUser,club_id,uid);
	}
}
